package cn.edu.hstc.wm.utils;

import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import cn.edu.hstc.wm.R;

/**
 * 跳转到指定Intent Activity的工具类
 * 
 */
public class IntentUtil {
	/**
	 * @param activity
	 *            当前的Activity
	 * @param cls
	 *            目的Activity
	 * @param name
	 *            传递的数据
	 */
	public static void startActivity(Context activity, Class<?> cls,
			BasicNameValuePair... name) {
		Intent intent = new Intent();
		intent.setClass(activity, cls);
		for (int i = 0; i < name.length; i++) {
			intent.putExtra(name[i].getName(), name[i].getValue());
		}
		activity.startActivity(intent);
		((Activity) activity).overridePendingTransition(R.anim.push_left_in,
				R.anim.push_left_out);
	}

	/**
	 * @param activity
	 *            当前的Activity
	 * @param cls
	 *            目的Activity
	 * @param bundle
	 *            传递的数据
	 */
	public static void startActivity(Context activity, Class<?> cls,
			Bundle bundle) {
		Intent intent = new Intent(activity, cls);
		intent.putExtras(bundle);
		activity.startActivity(intent);
		((Activity) activity).overridePendingTransition(R.anim.push_left_in,
				R.anim.push_left_out);
	}

	public static void startActivity(Context activity, Class<?> cls) {
		Intent intent = new Intent(activity, cls);
		activity.startActivity(intent);
		((Activity) activity).overridePendingTransition(R.anim.push_left_in,
				R.anim.push_left_out);
	}
	
}
